package edu.task.repository;

import edu.task.model.SysUserRole;
import edu.task.model.SysUserRolePK;
import edu.task.model.SysUserTask;
import edu.task.model.SysUserTaskPK;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface SysUserTaskRepository extends JpaRepository<SysUserTask, SysUserTaskPK> {

    @Modifying
    @Query(value = " delete ut from sys_user_task as ut " +
            "inner join sys_user as u on ut.user_id = u.user_id " +
            "inner join sys_task as t on ut.task_id = t.task_id " +
            "where ut.task_id=:taskId ", nativeQuery = true)
    void deleteUserTaskByTaskId(Long taskId);
}
